/**
 *
 */
package com.monkeyboy.controller;

import com.monkeyboy.common.dto.ResData;
import com.monkeyboy.model.LoginBody;
import com.monkeyboy.model.SysUser;
import com.monkeyboy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 *
 *
 * @author Gavin<br>
 *         2020年4月24日
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/user/login")
    public ResData login(@RequestBody LoginBody loginBody) throws Exception {
        String token = userService.login(loginBody);
        return ResData.SUCCESS_DATA(token);
    }

    @GetMapping("/user/getAllUser")
    public ResData getAllUser() throws Exception {
        ArrayList<SysUser> userList = userService.getAllUser();
        return ResData.SUCCESS_DATA(userList);
    }
}
